var e = require("../../../@babel/runtime/helpers/regeneratorRuntime"),
  t = require("../../../@babel/runtime/helpers/slicedToArray"),
  n = require("../../../@babel/runtime/helpers/asyncToGenerator"),
  r = require("../../../components/base/m-button/index"),
  o = require("../../../utils/helper/common/index");
Page({
  useStore: function (e) {
    return {
      customerServicePhone: '15207038013'
    }
  },
  data: {
    vx: ""
  },
  onLoad: function () {
    this.getVx()
  },
  onSubmit: (0, r.apply)(n(e().mark((function n() {
    var r, o, s, a, c;
    return e().wrap((function (e) {
      for (;;) switch (e.prev = e.next) {
        case 0:
          return e.next = 2, this.selectComponent("#form").verify({
            msg: [{
              lengthRange: {
                min: 15,
                max: 500
              },
              message: "至少要输入不少于15个字才能进行提交"
            }, {
              chinese: !0,
              message: "必须包含中文"
            }]
          });
        case 2:
          return r = e.sent, o = {
            msg: r.msg
          }, r.images && Object.assign(o, {
            images: r.images.map((function (e) {
              return e.url
            })).join()
          }), e.next = 7, $.request["POST/user/face-book?source=XCX"](o, {
            "content-type": "application/json"
          });
        case 7:
          s = e.sent, a = t(s, 1), 200 === (c = a[0]).code ? $.jxAlert({
            mode: "succ",
            content: c.msg
          }).then((function () {
            $.router.back()
          })) : $.jxAlert({
            mode: "error",
            content: c.msg
          });
        case 11:
        case "end":
          return e.stop()
      }
    }), n, this)
  })))),
  onCopy: function () {
    var e = this.data.vx;
    wx.setClipboardData({
      data: e,
      success: function () {
        wx.hideToast(), $.jxAlert({
          mode: "succ",
          content: "微信号:".concat(e, "已复制到粘贴板,去微信-添加朋友-搜索框粘贴!")
        })
      }
    })
  },
  onCall: function () {
    var e = this.data.customerServicePhone;
    (0, o.callPhone)(e)
  },
  getVx: function () {
    var r = this;
    return n(e().mark((function n() {
      var o, s, a;
      return e().wrap((function (e) {
        for (;;) switch (e.prev = e.next) {
          case 0:
            return e.next = 2, $.request["POST/us/wx-account?source=XCX"]({
              "content-type": "application/json"
            });
          case 2:
            o = e.sent, s = t(o, 1), 200 === (a = s[0]).code && r.setData({
              vx: a.content
            });
          case 6:
          case "end":
            return e.stop()
        }
      }), n)
    })))()
  }
});